package com.lp.biz.members.controller;

import com.lp.biz.members.model.vo.Members;
import com.lp.biz.members.service.BizMembersService;
import com.lp.common.annotation.PermissionAnnotation;
import com.lp.common.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.lp.common.constant.MenuConstant.CONTENT_READING;

/**
 * BizMembersController
 * @program: backend
 * @author Ke.Song
 * @since 2024-04-14 22:28:26
 */
@RestController
@RequestMapping("/members")
public class BizMembersController {

    @Autowired
    private BizMembersService membersService;

    /**
     * 获取共读会会员列表
     * @return 查询结果
     */
    @GetMapping("")
    @PermissionAnnotation(menus = {CONTENT_READING})
    public CommonResult getMembersList() {
        return membersService.getMembersList();
    }

    /**
     * 更新/添加会员价格
     * @param members 会员参数
     * @return 处理结果
     */
    @PostMapping("")
    @PermissionAnnotation(menus = {CONTENT_READING})
    public CommonResult updateMembers(@RequestBody @Validated List<Members> members) {
        membersService.updateMembers(members);
        return CommonResult.success();
    }
}
